﻿namespace Mercury.ParticleEngine.EmitterShapes
{
    using System;

    public sealed class SphereShape : IEmitterShape
    {
        public Single Radius { get; set; }

        public Boolean Shell { get; set; }

        public Boolean Radiate { get; set; }

        public ShapeResult GetOffsetAndDirection()
        {
            var distanceFromOrigin = Radius;
            
            if (!Shell)
                distanceFromOrigin = Radius * ExtensibilityPoints.RandomGenerator.NextSingle();

            var axis = ExtensibilityPoints.RandomGenerator.NextAxis();
            var translation = axis * distanceFromOrigin;

            if (!Radiate)
                axis = ExtensibilityPoints.RandomGenerator.NextAxis();

            return new ShapeResult(Coordinate.Origin + translation, axis);
        }
    }
}